import axios from 'services/axiosConfig.js'
import { ProductApi } from 'services/apiConfig.js'

class ProductService {
  getProductsByShopId(shopId) {
    return axios({
      method: ProductApi.getProductsByShopId.method,
      url: ProductApi.getProductsByShopId.url + '?Product.shopid=' + shopId
    })
  }
  getProductsByName(productName) {
    return axios({
      method: ProductApi.getProductsByName.method,
      url: ProductApi.getProductsByName.url + '?Product.name=(like)' + productName
    })
  }
  addProduct(product) {
    return axios({
      method: ProductApi.addProduct.method,
      url: ProductApi.addProduct.url,
      data: product
    })
  }
  updateProduct(newProduct) {
    return axios({
      method: ProductApi.updateProduct.method,
      url: ProductApi.updateProduct.url + newProduct.id,
      data: newProduct
    })
  }
}

export default new ProductService()
